package ms;

import java.util.HashMap;
import java.util.Map;

public class map1 {
    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("111", "abc");
        map.put("112", "abcd");
        map.put("1123", "abcde");

        //遍历方式
        for (String key : map.keySet()) {
            System.out.println(key + " " + map.get(key));
        }

        //只需要遍历值
        for (String str : map.values()) {
            System.out.println(str);
        }
        //表示键值对的 Entry
        for (Map.Entry<String, String> entry : map.entrySet()) {
            String key = entry.getKey();
            String value = entry.getValue();
        }

        //stream流
        map.entrySet().forEach(entry -> {
            System.out.println(entry.getKey() + " " + entry.getValue());
        });
    }
}
